package hz.mobileproject.pda.toolsmanager.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;

import java.util.List;

import hz.mobileproject.pda.R;
import hz.mobileproject.pda.toolsmanager.bean.response.RP_ToolInfo;
import hz.mobileproject.pda.ui.base.BaseCustomAdapter;

/**
 * Created by Alex on 2018/4/27.
 */

public class WaiJieToolsAdapter extends BaseCustomAdapter<RP_ToolInfo,WaiJieToolsAdapter.ViewHolder> {


    public WaiJieToolsAdapter(Context mContext, List<RP_ToolInfo> list) {
        super(mContext, list);
    }

    @Override
    protected int bindView() {
        return R.layout.item_waijie_tools;
    }

    @Override
    protected ViewHolder createViewHolder() {
        return new ViewHolder();
    }

    @Override
    protected void bindData(final int position, View convertView, ViewHolder viewHolder) {
        viewHolder.mPosition = position;
        RP_ToolInfo bean = mList.get(position);
        viewHolder.tv_tool_lx.setText(bean.getTool_type_name());
        viewHolder.tv_tool_name.setText(bean.getTool_name());

    }



    class ViewHolder {
        @ViewInject(R.id.tv_tool_lx)
        private TextView tv_tool_lx;
        @ViewInject(R.id.tv_tool_name)
        private TextView tv_tool_name;
        private int mPosition;

        @Event({R.id.tv_delete})
        private void onViewClick(View v){
            switch (v.getId()){
                case R.id.tv_delete:
                    WaiJieToolsAdapter.this.deleteOne(mPosition);
                    break;
            }
        }
    }

    public void clearAll() {
        mList.clear();
        notifyDataSetChanged();
    }
}
